package juego.escenario;

import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

import juego.graficos.*;

public class Actualizador extends Thread {
	
	protected JLabel labelMario;
	private Nivel level;
	
	public Actualizador(JLabel labelMario, Nivel level)
	{
		this.labelMario = labelMario;
		this.level = level;
	}
	
	public void run()
	{
		while (true)
		{
			try
			{
				if(level.getEntidad(this.labelMario.getLocation().y/32, this.labelMario.getLocation().x/32).esTransitable())
				{
					this.labelMario.setLocation(this.labelMario.getLocation().x + 10, this.labelMario.getLocation().y);
					Thread.sleep(100);
				}
				else
				{
					this.labelMario.setLocation(this.labelMario.getLocation().x, this.labelMario.getLocation().y);
					Thread.sleep(100);
				}
			} catch (Exception e)
			{
				e.getMessage();
			}
		}
	}

}
